package com.tencreat.mall.controller.app;


import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;

/**
 * @author huang wei
 * @version 1.0
 * @date 2021/11/15 17:15
 */
public class MySpringConfigurator {


    private static volatile BeanFactory context;


    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        MySpringConfigurator.context = applicationContext;
    }

    public <T> T getEndpointInstance(Class<T> clazz) throws InstantiationException {
        return context.getBean(clazz);
    }

}
